﻿using log4net;
using RabbitMQ.Client.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wq.Core.Extensions.Assembly.RabbitMQ;

namespace Wq.RabbitMQ
{
    /// <summary>
    /// 订单队列
    /// </summary>
    [RabbitAttribute("OrderEvent.Payment", "payment", true)]
    public class OrderEvents: RabbitListener
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(RabbitListener));
        /// <summary>
        /// 订单支付
        /// </summary>
        /// <param name="orderId"></param>
        public void Payment(string orderId)
        {
            Publish(orderId, 50000);
            Subscribe();
        }

        /// <summary>
        /// 消费
        /// </summary>
        public void Handler(string msgBody)
        {
            Console.WriteLine(string.Format("msgBody接收时间:{0}，消息内容：{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msgBody));
        }
    }
}
